package com.neu.constant;

public enum RoleEnum {
    ADMIN(10, "admin"),
    EDITOR(20, "editor"),
    VISITOR(30, "visitor"),
    UNKNOWN(-1, "未知");

    public final int code;
    public final String des;

    RoleEnum(int code, String des) {
        this.code = code;
        this.des = des;
    }

    public static RoleEnum of(int code) {
        if (code == ADMIN.code) {
            return ADMIN;
        } else if (code == EDITOR.code) {
            return EDITOR;
        } else if (code == VISITOR.code) {
            return VISITOR;
        } else {
            return UNKNOWN;
        }
    }
}
